const {defineConfig} = require('@vue/cli-service')
const path = require("path");

function resolve(dir) {
    return path.join(__dirname, dir)
}

const name = 'ACARGID-WEB' // page title

module.exports = defineConfig({
    transpileDependencies: true, publicPath: "./",
    devServer: {
        client: {
            overlay: false,
        },
        proxy: {
            '/api': {
                target: 'http://localhost:8012',
                changeOrigin: true,
                pathRewrite: {'^/api': ''}
            },
        }
    },
    configureWebpack: {
        // provide the app's title in webpack's name field, so that
        // it can be accessed in index.html to inject the correct title.
        name: name,
        resolve: {
            alias: {
                '@': resolve('src')
            }
        }
    },
    chainWebpack(config) {
        // set svg-sprite-loader
        // const dir = path.resolve(__dirname, 'src/icons')
        config.module
            .rule('svg')
            .exclude.add(resolve('src/icons'))
            .end()
        config.module
            .rule('icons')
            .test(/\.svg$/)
            .include.add(resolve('src/icons'))
            .end()
            .use('svg-sprite-loader')
            .loader('svg-sprite-loader')
            .options({
                symbolId: 'icon-[name]'
            })
            .end()
    }
})
